/*
 * Core.cpp
 *
 *  Created on: Sep 29, 2009
 *      Author: tiago.zaccaro
 */

#include "Core.h"

namespace AcquaEngine {

Core::Core() {
	mGraphicsManager = new Graphics::GraphicsManager();
}

Core::~Core() {
}

bool Core::initialise() {
	if (!getGraphicsManager()->initialise()) return false;

	Graphics::Camera *camera = getGraphicsManager()->createCamera("Camera1");

	getGraphicsManager()->createViewport(camera->getCamera(), Ogre::Root::getSingleton().getAutoCreatedWindow());

	GameStates::GameScreen *gameScreen = new GameStates::GameScreen();

	gameScreen->enter();

	return true;
}

void Core::run() {
    // Infinite loop, until broken out of by frame listeners
    // or break out by calling queueEndRendering()
    bool mQueuedEnd = false;

    while( !mQueuedEnd )
    {
		//Pump messages in all registered RenderWindow windows
    	WindowEventUtilities::messagePump();

		if (!getGraphicsManager()->getRoot()->renderOneFrame())
			break;
    }

	getGraphicsManager()->destroy();
}

Graphics::GraphicsManager *Core::getGraphicsManager() {
	return mGraphicsManager;
}

}
